package edu.hitsz.application;

import edu.hitsz.application.Game.EasyGame;
import edu.hitsz.application.Game.Game;
import edu.hitsz.application.Game.HardGame;
import edu.hitsz.application.Game.NormalGame;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class GameStartScreen {
    private JPanel MainPanel;
    private JButton easyButton;
    private JButton normalButton;
    private JButton hardButton;
    private JComboBox musicComboBox;
    private JLabel music;
    private JPanel bottomPanel;
    private JPanel topPanel;



    public GameStartScreen() {

        Main.musicState=Main.MUSIC_ON;

        easyButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                Main.gameMode=Main.EASY_MODE;
                System.out.println("简单模式，游戏开始");

                Game game=new EasyGame();
                Main.cardPanel.add(game);
                Main.cardLayout.last(Main.cardPanel);
                game.action();
            }
        });

        normalButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                Main.gameMode=Main.NORMAL_MODE;
                System.out.println("普通模式，游戏开始");

                Game game=new NormalGame();
                Main.cardPanel.add(game);
                Main.cardLayout.last(Main.cardPanel);
                game.action();
            }
        });


        hardButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                Main.gameMode=Main.HARD_MODE;

                System.out.println("困难模式，游戏开始");

                Game game=new HardGame();
                Main.cardPanel.add(game);
                Main.cardLayout.last(Main.cardPanel);
                game.action();
            }
        });


        musicComboBox.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                System.out.println(musicComboBox.getSelectedItem());
                if (musicComboBox.getSelectedItem()=="开"){
                    Main.musicState=Main.MUSIC_ON;
                }else {
                    Main.musicState=Main.MUSIC_OFF;
                }
            }
        });

    }

    public JPanel getMainPanel() {
        return MainPanel;
    }
}
